<!--
 * @Description:业务表格搜索
 * @Version: 2.0
 * @Autor: kafei
 * @Date: 2021-11-29 15:25:08
 * @LastEditors: kafei
 * @LastEditTime: 2021-11-30 16:00:23
-->
<template>
  <div class="tableSearch__formSearch flex">
    <div class="tableSearch__formSearch--left">
      <Form
        ref="form"
        :item-data="itemData"
      />
    </div>
    <div class="tableSearch__formSearch--right">
      <ButtonConfig
        :button-data="buttonData"
        class="flex"
        @click="handClick"
      />
    </div>
  </div>
</template>

<script>
import Form from '@/components/Form/index.vue'
import ButtonConfig from '@/components/ButtonConfig/index.vue'
export default {
  name: 'FormSearch',
  components: {
    Form,
    ButtonConfig
  },
  props: {
    itemData: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data () {
    return {
      buttonData: [
        {
          text: '搜索',
          type: 'primary',
          icon: 'el-icon-search',
          action: 'search'
        },
        {
          text: '重置',
          type: 'warning',
          icon: 'el-icon-refresh',
          action: 'reset'
        }
      ]
    }
  },
  methods: {
    handClick (item) {
      if (item.action === 'reset') {
        this.$refs.form.resetForm()
      } else if (item.action === 'search') {
        this.$emit('search', this.$refs.form.form)
      }
    }
  }
}
</script>

<style>

</style>
